const fs = require('fs');
const path = require('path');
var tools = require('../../../libs/tools');
var config = require(tools.rootPath + 'config');
var { connection, pool, model } = require(tools.rootPath + 'libs/model');

var controller = require(tools.rootPath + 'libs/controller.js');


module.exports = class extends controller {
    constructor() {
        super();
    }
    async index(req, res) {
        if (req.ispost) {
            console.log(req.body);
            //custom submit
            //hobby
            //{"submit":"提交"}
            //{"hobby":"1","submit":"提交"}
            //{"hobby":["1","2"],"submit":"提交"}
            //{"hobby":["1","2","3"],"submit":"提交"}

            //hobby[]
            //{"submit":"提交"}
            //{"hobby[]":"1","submit":"提交"}
            //{"hobby[]":["1","2"],"submit":"提交"}
            //{"hobby[]":["1","2","3"],"submit":"提交"}

            //ajax submit
            //hobby
            //{}
            //{ hobby: '1' }
            //{ hobby: [ '1', '2' ] }
            //{ hobby: [ '1', '2', '3' ] }

            //hobby[]
            //{}
            //{ 'hobby[]': '1' }
            //{ 'hobby[]': [ '1', '2' ] }
            //{ 'hobby[]': [ '1', '2', '3' ] }
            res.json(req.body);
            return;
        }
        res.render(req.TPL, {});
    }

}